import { v4 as uuidv4 } from 'uuid'

// 生成随机字符串作为游客身份持久存储，保证用户唯一性
export const getUUID = ()=> {
  // 先校验本地是否已存在UUID 有则返回 无则生成并本地存储
  let uuid_token = localStorage.getItem('UUIDTOKEN')
  if (!uuid_token) {
    uuid_token = uuidv4()
    localStorage.setItem('UUIDTOKEN', uuid_token)
  }
  return uuid_token
}